<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>法条管理</title>
<link rel="stylesheet" type="text/css" href="css/css.css" />
<script type="text/javascript" src="js/jquery.min.js"></script>
<!-- <script type="text/javascript" src="js/page.js" ></script> -->
</head>

<body>
	<div id="pageAll">
		<div class="pageTop">
			<div class="page">
				<span><a href="user.html">首页</a>&nbsp;-&nbsp;</span>&nbsp;法条管理
			</div>
		</div>

		<div class="page" id="app">
			<!-- user页面样式 -->
			<div class="connoisseur">
				<div class="conform">
				<form>
						<div class="cfD">
							<button class="userbtn"><a href="lawadd.html">新增法条</button>
						</div>
					</form>
				</div>
				<!-- user 表格 显示 -->
				<div class="conShow">
					<table border="1" cellspacing="0" cellpadding="0">
						<tr>
							<td width="66px" class="tdColor tdC">序号</td>
							<td width="800px" class="tdColor">法条标题</td>
							<td width="635px" class="tdColor">链接地址</td>
							<td width="435px" class="tdColor">日期</td>
							<td width="500px" class="tdColor">操作</td>
						</tr>
						<tr height="40px" v-for="law in laws">
							<td>{{law.serialkey}}</td>
							<td>{{law.lawtit}}</td>
							<td>{{law.lawlink}}</td>
							<td>{{law.lawdate}}</td>
							<td><a href="#" @click="dele(law.serialkey)">删除</a></td>
						</tr>
					</table>
				</div>
				<!-- user 表格 显示 end-->
			</div>
			<!-- user页面样式end -->
		</div>

	</div>


	<!-- 删除弹出框 -->
	<div class="banDel">
		<div class="delete">
			<div class="close">
				<a><img src="img/shanchu.png" /></a>
			</div>
			<p class="delP1">你确定要删除此条记录吗？</p>
			<p class="delP2">
				<a href="#" class="ok yes">确定</a><a class="ok no">取消</a>
			</p>
		</div>
	</div>
	<!-- 删除弹出框  end-->
</body>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<script src="https://cdn.jsdelivr.net/npm/vue-resource@1.5.0"></script>
<script type="text/javascript">
	new Vue({
		el: '#app',
		data() {
			return {
				laws: []
			}
		},
		beforeMount: function() {
			this.$http.get(`http://localhost:8080/law/query`)
			.then(res =>{
				let data = res.body;
				if(data.code === '200') {
					let list = data.list;
					list.map((ls)=>{
						ls.lawdate = ls.lawdate.split('T')[0];
					});
					this.laws = list;
				}else {
					alert(data.desc);
				}
			},
			res => {
				alert(`网络异常`);
			});
		},
		methods: {
		dele: function(id) {
				this.$http.get(`http://localhost:8080/law/delete/${id}`)
				.then(
					res => {
						let data = res.body;
						if(data.code === '200') {
							alert('删除成功');
						}else {
							alert(data.desc);
						}
					},
					res => {
						alert(`网络异常`);
					}
				)
			}
	}
	});
</script>
</html>